home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / info.lzh / INFO / GCC_INFO.9 < prev   
Encoding:
GNU Info File  |  1993-10-21  |  48.4 KB  |  1,053 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. File: gcc.info,  Node: VMS Misc,  Prev: Global Declarations,  Up: VMS
  28.  
  29. Other VMS Issues
  30. ================
  31.  
  32.    GNU CC automatically arranges for `main' to return 1 by default if
  33. you fail to specify an explicit return value.  This will be interpreted
  34. by VMS as a status code indicating a normal successful completion.
  35. Version 1 of GNU CC did not provide this default.
  36.  
  37.    GNU CC on VMS works only with the GNU assembler, GAS.  You need
  38. version 1.37 or later of GAS in order to produce value debugging
  39. information for the VMS debugger.  Use the ordinary VMS linker with the
  40. object files produced by GAS.
  41.  
  42.    Under previous versions of GNU CC, the generated code would
  43. occasionally give strange results when linked to the sharable `VAXCRTL'
  44. library.  Now this should work.
  45.  
  46.    A caveat for use of `const' global variables: the `const' modifier
  47. must be specified in every external declaration of the variable in all
  48. of the source files that use that variable.  Otherwise the linker will
  49. issue warnings about conflicting attributes for the variable.  Your
  50. program will still work despite the warnings, but the variable will be
  51. placed in writable storage.
  52.  
  53.    Although the VMS linker does distinguish between upper and lower case
  54. letters in global symbols, most VMS compilers convert all such symbols
  55. into upper case and most run-time library routines also have upper case
  56. names.  To be able to reliably call such routines, GNU CC (by means of
  57. the assembler GAS) converts global symbols into upper case like other
  58. VMS compilers.  However, since the usual practice in C is to distinguish
  59. case, GNU CC (via GAS) tries to preserve usual C behavior by augmenting
  60. each name that is not all lower case.  This means truncating the name
  61. to at most 23 characters and then adding more characters at the end
  62. which encode the case pattern of those 23.   Names which contain at
  63. least one dollar sign are an exception; they are converted directly into
  64. upper case without augmentation.
  65.  
  66.    Name augmentation yields bad results for programs that use
  67. precompiled libraries (such as Xlib) which were generated by another
  68. compiler.  You can use the compiler option `/NOCASE_HACK' to inhibit
  69. augmentation; it makes external C functions and variables
  70. case-independent as is usual on VMS.  Alternatively, you could write
  71. all references to the functions and variables in such libraries using
  72. lower case; this will work on VMS, but is not portable to other
  73. systems.  The compiler option `/NAMES' also provides control over
  74. global name handling.
  75.  
  76.    Function and variable names are handled somewhat differently with GNU
  77. C++.  The GNU C++ compiler performs "name mangling" on function names,
  78. which means that it adds information to the function name to describe
  79. the data types of the arguments that the function takes.  One result of
  80. this is that the name of a function can become very long.  Since the
  81. VMS linker only recognizes the first 31 characters in a name, special
  82. action is taken to ensure that each function and variable has a unique
  83. name that can be represented in 31 characters.
  84.  
  85.    If the name (plus a name augmentation, if required) is less than 32
  86. characters in length, then no special action is performed.  If the name
  87. is longer than 31 characters, the assembler (GAS) will generate a hash
  88. string based upon the function name, truncate the function name to 23
  89. characters, and append the hash string to the truncated name.  If the
  90. `/VERBOSE' compiler option is used, the assembler will print both the
  91. full and truncated names of each symbol that is truncated.
  92.  
  93.    The `/NOCASE_HACK' compiler option should not be used when you are
  94. compiling programs that use libg++.  libg++ has several instances of
  95. objects (i.e.  `Filebuf' and `filebuf') which become indistinguishable
  96. in a case-insensitive environment.  This leads to cases where you need
  97. to inhibit augmentation selectively (if you were using libg++ and Xlib
  98. in the same program, for example).  There is no special feature for
  99. doing this, but you can get the result by defining a macro for each
  100. mixed case symbol for which you wish to inhibit augmentation.  The
  101. macro should expand into the lower case equivalent of itself.  For
  102. example:
  103.  
  104.      #define StuDlyCapS studlycaps
  105.  
  106.    These macro definitions can be placed in a header file to minimize
  107. the number of changes to your source code.
  108.  
  109. File: gcc.info,  Node: Portability,  Next: Interface,  Prev: VMS,  Up: Top
  110.  
  111. GNU CC and Portability
  112. **********************
  113.  
  114.    The main goal of GNU CC was to make a good, fast compiler for
  115. machines in the class that the GNU system aims to run on: 32-bit
  116. machines that address 8-bit bytes and have several general registers.
  117. Elegance, theoretical power and simplicity are only secondary.
  118.  
  119.    GNU CC gets most of the information about the target machine from a
  120. machine description which gives an algebraic formula for each of the
  121. machine's instructions.  This is a very clean way to describe the
  122. target.  But when the compiler needs information that is difficult to
  123. express in this fashion, I have not hesitated to define an ad-hoc
  124. parameter to the machine description.  The purpose of portability is to
  125. reduce the total work needed on the compiler; it was not of interest
  126. for its own sake.
  127.  
  128.    GNU CC does not contain machine dependent code, but it does contain
  129. code that depends on machine parameters such as endianness (whether the
  130. most significant byte has the highest or lowest address of the bytes in
  131. a word) and the availability of autoincrement addressing.  In the
  132. RTL-generation pass, it is often necessary to have multiple strategies
  133. for generating code for a particular kind of syntax tree, strategies
  134. that are usable for different combinations of parameters.  Often I have
  135. not tried to address all possible cases, but only the common ones or
  136. only the ones that I have encountered.  As a result, a new target may
  137. require additional strategies.  You will know if this happens because
  138. the compiler will call `abort'.  Fortunately, the new strategies can be
  139. added in a machine-independent fashion, and will affect only the target
  140. machines that need them.
  141.  
  142. File: gcc.info,  Node: Interface,  Next: Passes,  Prev: Portability,  Up: Top
  143.  
  144. Interfacing to GNU CC Output
  145. ****************************
  146.  
  147.    GNU CC is normally configured to use the same function calling
  148. convention normally in use on the target system.  This is done with the
  149. machine-description macros described (*note Target Macros::.).
  150.  
  151.    However, returning of structure and union values is done differently
  152. on some target machines.  As a result, functions compiled with PCC
  153. returning such types cannot be called from code compiled with GNU CC,
  154. and vice versa.  This does not cause trouble often because few Unix
  155. library routines return structures or unions.
  156.  
  157.    GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes
  158. long in the same registers used for `int' or `double' return values.
  159. (GNU CC typically allocates variables of such types in registers also.)
  160. Structures and unions of other sizes are returned by storing them into
  161. an address passed by the caller (usually in a register).  The
  162. machine-description macros `STRUCT_VALUE' and `STRUCT_INCOMING_VALUE'
  163. tell GNU CC where to pass this address.
  164.  
  165.    By contrast, PCC on most target machines returns structures and
  166. unions of any size by copying the data into an area of static storage,
  167. and then returning the address of that storage as if it were a pointer
  168. value.  The caller must copy the data from that memory area to the
  169. place where the value is wanted.  This is slower than the method used
  170. by GNU CC, and fails to be reentrant.
  171.  
  172.    On some target machines, such as RISC machines and the 80386, the
  173. standard system convention is to pass to the subroutine the address of
  174. where to return the value.  On these machines, GNU CC has been
  175. configured to be compatible with the standard compiler, when this method
  176. is used.  It may not be compatible for structures of 1, 2, 4 or 8 bytes.
  177.  
  178.    GNU CC uses the system's standard convention for passing arguments.
  179. On some machines, the first few arguments are passed in registers; in
  180. others, all are passed on the stack.  It would be possible to use
  181. registers for argument passing on any machine, and this would probably
  182. result in a significant speedup.  But the result would be complete
  183. incompatibility with code that follows the standard convention.  So this
  184. change is practical only if you are switching to GNU CC as the sole C
  185. compiler for the system.  We may implement register argument passing on
  186. certain machines once we have a complete GNU system so that we can
  187. compile the libraries with GNU CC.
  188.  
  189.    On some machines (particularly the Sparc), certain types of arguments
  190. are passed "by invisible reference".  This means that the value is
  191. stored in memory, and the address of the memory location is passed to
  192. the subroutine.
  193.  
  194.    If you use `longjmp', beware of automatic variables.  ANSI C says
  195. that automatic variables that are not declared `volatile' have undefined
  196. values after a `longjmp'.  And this is all GNU CC promises to do,
  197. because it is very difficult to restore register variables correctly,
  198. and one of GNU CC's features is that it can put variables in registers
  199. without your asking it to.
  200.  
  201.    If you want a variable to be unaltered by `longjmp', and you don't
  202. want to write `volatile' because old C compilers don't accept it, just
  203. take the address of the variable.  If a variable's address is ever
  204. taken, even if just to compute it and ignore it, then the variable
  205. cannot go in a register:
  206.  
  207.      {
  208.        int careful;
  209.        &careful;
  210.        ...
  211.      }
  212.  
  213.    Code compiled with GNU CC may call certain library routines.  Most of
  214. them handle arithmetic for which there are no instructions.  This
  215. includes multiply and divide on some machines, and floating point
  216. operations on any machine for which floating point support is disabled
  217. with `-msoft-float'.  Some standard parts of the C library, such as
  218. `bcopy' or `memcpy', are also called automatically.  The usual function
  219. call interface is used for calling the library routines.
  220.  
  221.    These library routines should be defined in the library `libgcc.a',
  222. which GNU CC automatically searches whenever it links a program.  On
  223. machines that have multiply and divide instructions, if hardware
  224. floating point is in use, normally `libgcc.a' is not needed, but it is
  225. searched just in case.
  226.  
  227.    Each arithmetic function is defined in `libgcc1.c' to use the
  228. corresponding C arithmetic operator.  As long as the file is compiled
  229. with another C compiler, which supports all the C arithmetic operators,
  230. this file will work portably.  However, `libgcc1.c' does not work if
  231. compiled with GNU CC, because each arithmetic function would compile
  232. into a call to itself!
  233.  
  234. File: gcc.info,  Node: Passes,  Next: RTL,  Prev: Interface,  Up: Top
  235.  
  236. Passes and Files of the Compiler
  237. ********************************
  238.  
  239.    The overall control structure of the compiler is in `toplev.c'.  This
  240. file is responsible for initialization, decoding arguments, opening and
  241. closing files, and sequencing the passes.
  242.  
  243.    The parsing pass is invoked only once, to parse the entire input.
  244. The RTL intermediate code for a function is generated as the function
  245. is parsed, a statement at a time.  Each statement is read in as a
  246. syntax tree and then converted to RTL; then the storage for the tree
  247. for the statement is reclaimed.  Storage for types (and the expressions
  248. for their sizes), declarations, and a representation of the binding
  249. contours and how they nest, remain until the function is finished being
  250. compiled; these are all needed to output the debugging information.
  251.  
  252.    Each time the parsing pass reads a complete function definition or
  253. top-level declaration, it calls either the function
  254. `rest_of_compilation', or the function `rest_of_decl_compilation' in
  255. `toplev.c', which are responsible for all further processing necessary,
  256. ending with output of the assembler language.  All other compiler
  257. passes run, in sequence, within `rest_of_compilation'.  When that
  258. function returns from compiling a function definition, the storage used
  259. for that function definition's compilation is entirely freed, unless it
  260. is an inline function (*note An Inline Function is As Fast As a Macro:
  261. Inline.).
  262.  
  263.    Here is a list of all the passes of the compiler and their source
  264. files.  Also included is a description of where debugging dumps can be
  265. requested with `-d' options.
  266.  
  267.    * Parsing.  This pass reads the entire text of a function definition,
  268.      constructing partial syntax trees.  This and RTL generation are no
  269.      longer truly separate passes (formerly they were), but it is
  270.      easier to think of them as separate.
  271.  
  272.      The tree representation does not entirely follow C syntax, because
  273.      it is intended to support other languages as well.
  274.  
  275.      Language-specific data type analysis is also done in this pass,
  276.      and every tree node that represents an expression has a data type
  277.      attached.  Variables are represented as declaration nodes.
  278.  
  279.      Constant folding and some arithmetic simplifications are also done
  280.      during this pass.
  281.  
  282.      The language-independent source files for parsing are
  283.      `stor-layout.c', `fold-const.c', and `tree.c'.  There are also
  284.      header files `tree.h' and `tree.def' which define the format of
  285.      the tree representation.
  286.  
  287.      The source files to parse C are `c-parse.y', `c-decl.c',
  288.      `c-typeck.c', `c-aux-info.c', `c-convert.c', and `c-lang.c' along
  289.      with header files `c-lex.h', and `c-tree.h'.
  290.  
  291.      The source files for parsing C++ are `cp-parse.y', `cp-class.c',
  292.      `cp-cvt.c', `cp-decl.c', `cp-decl2.c', `cp-dem.c', `cp-except.c',
  293.      `cp-expr.c', `cp-init.c', `cp-lex.c', `cp-method.c', `cp-ptree.c',
  294.      `cp-search.c', `cp-tree.c', `cp-type2.c', and `cp-typeck.c', along
  295.      with header files `cp-tree.def', `cp-tree.h', and `cp-decl.h'.
  296.  
  297.      The special source files for parsing Objective C are
  298.      `objc-parse.y', `objc-actions.c', `objc-tree.def', and
  299.      `objc-actions.h'.  Certain C-specific files are used for this as
  300.      well.
  301.  
  302.      The file `c-common.c' is also used for all of the above languages.
  303.  
  304.    * RTL generation.  This is the conversion of syntax tree into RTL
  305.      code.  It is actually done statement-by-statement during parsing,
  306.      but for most purposes it can be thought of as a separate pass.
  307.  
  308.      This is where the bulk of target-parameter-dependent code is found,
  309.      since often it is necessary for strategies to apply only when
  310.      certain standard kinds of instructions are available.  The purpose
  311.      of named instruction patterns is to provide this information to
  312.      the RTL generation pass.
  313.  
  314.      Optimization is done in this pass for `if'-conditions that are
  315.      comparisons, boolean operations or conditional expressions.  Tail
  316.      recursion is detected at this time also.  Decisions are made about
  317.      how best to arrange loops and how to output `switch' statements.
  318.  
  319.      The source files for RTL generation include `stmt.c', `calls.c',
  320.      `expr.c', `explow.c', `expmed.c', `function.c', `optabs.c' and
  321.      `emit-rtl.c'.  Also, the file `insn-emit.c', generated from the
  322.      machine description by the program `genemit', is used in this
  323.      pass.  The header file `expr.h' is used for communication within
  324.      this pass.
  325.  
  326.      The header files `insn-flags.h' and `insn-codes.h', generated from
  327.      the machine description by the programs `genflags' and `gencodes',
  328.      tell this pass which standard names are available for use and
  329.      which patterns correspond to them.
  330.  
  331.      Aside from debugging information output, none of the following
  332.      passes refers to the tree structure representation of the function
  333.      (only part of which is saved).
  334.  
  335.      The decision of whether the function can and should be expanded
  336.      inline in its subsequent callers is made at the end of rtl
  337.      generation.  The function must meet certain criteria, currently
  338.      related to the size of the function and the types and number of
  339.      parameters it has.  Note that this function may contain loops,
  340.      recursive calls to itself (tail-recursive functions can be
  341.      inlined!), gotos, in short, all constructs supported by GNU CC.
  342.      The file `integrate.c' contains the code to save a function's rtl
  343.      for later inlining and to inline that rtl when the function is
  344.      called.  The header file `integrate.h' is also used for this
  345.      purpose.
  346.  
  347.      The option `-dr' causes a debugging dump of the RTL code after
  348.      this pass.  This dump file's name is made by appending `.rtl' to
  349.      the input file name.
  350.  
  351.    * Jump optimization.  This pass simplifies jumps to the following
  352.      instruction, jumps across jumps, and jumps to jumps.  It deletes
  353.      unreferenced labels and unreachable code, except that unreachable
  354.      code that contains a loop is not recognized as unreachable in this
  355.      pass.  (Such loops are deleted later in the basic block analysis.)
  356.      It also converts some code originally written with jumps into
  357.      sequences of instructions that directly set values from the
  358.      results of comparisons, if the machine has such instructions.
  359.  
  360.      Jump optimization is performed two or three times.  The first time
  361.      is immediately following RTL generation.  The second time is after
  362.      CSE, but only if CSE says repeated jump optimization is needed.
  363.      The last time is right before the final pass.  That time,
  364.      cross-jumping and deletion of no-op move instructions are done
  365.      together with the optimizations described above.
  366.  
  367.      The source file of this pass is `jump.c'.
  368.  
  369.      The option `-dj' causes a debugging dump of the RTL code after
  370.      this pass is run for the first time.  This dump file's name is
  371.      made by appending `.jump' to the input file name.
  372.  
  373.    * Register scan.  This pass finds the first and last use of each
  374.      register, as a guide for common subexpression elimination.  Its
  375.      source is in `regclass.c'.
  376.  
  377.    * Jump threading.  This pass detects a condition jump that branches
  378.      to an identical or inverse test.  Such jumps can be `threaded'
  379.      through the second conditional test.  The source code for this
  380.      pass is in `jump.c'.  This optimization is only performed if
  381.      `-fthread-jumps' is enabled.
  382.  
  383.    * Common subexpression elimination.  This pass also does constant
  384.      propagation.  Its source file is `cse.c'.  If constant propagation
  385.      causes conditional jumps to become unconditional or to become
  386.      no-ops, jump optimization is run again when CSE is finished.
  387.  
  388.      The option `-ds' causes a debugging dump of the RTL code after
  389.      this pass.  This dump file's name is made by appending `.cse' to
  390.      the input file name.
  391.  
  392.    * Loop optimization.  This pass moves constant expressions out of
  393.      loops, and optionally does strength-reduction and loop unrolling
  394.      as well.  Its source files are `loop.c' and `unroll.c', plus the
  395.      header `loop.h' used for communication between them.  Loop
  396.      unrolling uses some functions in `integrate.c' and the header
  397.      `integrate.h'.
  398.  
  399.      The option `-dL' causes a debugging dump of the RTL code after
  400.      this pass.  This dump file's name is made by appending `.loop' to
  401.      the input file name.
  402.  
  403.    * If `-frerun-cse-after-loop' was enabled, a second common
  404.      subexpression elimination pass is performed after the loop
  405.      optimization pass.  Jump threading is also done again at this time
  406.      if it was specified.
  407.  
  408.      The option `-dt' causes a debugging dump of the RTL code after
  409.      this pass.  This dump file's name is made by appending `.cse2' to
  410.      the input file name.
  411.  
  412.    * Stupid register allocation is performed at this point in a
  413.      nonoptimizing compilation.  It does a little data flow analysis as
  414.      well.  When stupid register allocation is in use, the next pass
  415.      executed is the reloading pass; the others in between are skipped.
  416.      The source file is `stupid.c'.
  417.  
  418.    * Data flow analysis (`flow.c').  This pass divides the program into
  419.      basic blocks (and in the process deletes unreachable loops); then
  420.      it computes which pseudo-registers are live at each point in the
  421.      program, and makes the first instruction that uses a value point at
  422.      the instruction that computed the value.
  423.  
  424.      This pass also deletes computations whose results are never used,
  425.      and combines memory references with add or subtract instructions
  426.      to make autoincrement or autodecrement addressing.
  427.  
  428.      The option `-df' causes a debugging dump of the RTL code after
  429.      this pass.  This dump file's name is made by appending `.flow' to
  430.      the input file name.  If stupid register allocation is in use, this
  431.      dump file reflects the full results of such allocation.
  432.  
  433.    * Instruction combination (`combine.c').  This pass attempts to
  434.      combine groups of two or three instructions that are related by
  435.      data flow into single instructions.  It combines the RTL
  436.      expressions for the instructions by substitution, simplifies the
  437.      result using algebra, and then attempts to match the result
  438.      against the machine description.
  439.  
  440.      The option `-dc' causes a debugging dump of the RTL code after
  441.      this pass.  This dump file's name is made by appending `.combine'
  442.      to the input file name.
  443.  
  444.    * Instruction scheduling (`sched.c').  This pass looks for
  445.      instructions whose output will not be available by the time that
  446.      it is used in subsequent instructions.  (Memory loads and floating
  447.      point instructions often have this behavior on RISC machines).  It
  448.      re-orders instructions within a basic block to try to separate the
  449.      definition and use of items that otherwise would cause pipeline
  450.      stalls.
  451.  
  452.      Instruction scheduling is performed twice.  The first time is
  453.      immediately after instruction combination and the second is
  454.      immediately after reload.
  455.  
  456.      The option `-dS' causes a debugging dump of the RTL code after this
  457.      pass is run for the first time.  The dump file's name is made by
  458.      appending `.sched' to the input file name.
  459.  
  460.    * Register class preferencing.  The RTL code is scanned to find out
  461.      which register class is best for each pseudo register.  The source
  462.      file is `regclass.c'.
  463.  
  464.    * Local register allocation (`local-alloc.c').  This pass allocates
  465.      hard registers to pseudo registers that are used only within one
  466.      basic block.  Because the basic block is linear, it can use fast
  467.      and powerful techniques to do a very good job.
  468.  
  469.      The option `-dl' causes a debugging dump of the RTL code after
  470.      this pass.  This dump file's name is made by appending `.lreg' to
  471.      the input file name.
  472.  
  473.    * Global register allocation (`global.c').  This pass allocates hard
  474.      registers for the remaining pseudo registers (those whose life
  475.      spans are not contained in one basic block).
  476.  
  477.    * Reloading.  This pass renumbers pseudo registers with the hardware
  478.      registers numbers they were allocated.  Pseudo registers that did
  479.      not get hard registers are replaced with stack slots.  Then it
  480.      finds instructions that are invalid because a value has failed to
  481.      end up in a register, or has ended up in a register of the wrong
  482.      kind.  It fixes up these instructions by reloading the
  483.      problematical values temporarily into registers.  Additional
  484.      instructions are generated to do the copying.
  485.  
  486.      The reload pass also optionally eliminates the frame pointer and
  487.      inserts instructions to save and restore call-clobbered registers
  488.      around calls.
  489.  
  490.      Source files are `reload.c' and `reload1.c', plus the header
  491.      `reload.h' used for communication between them.
  492.  
  493.      The option `-dg' causes a debugging dump of the RTL code after
  494.      this pass.  This dump file's name is made by appending `.greg' to
  495.      the input file name.
  496.  
  497.    * Instruction scheduling is repeated here to try to avoid pipeline
  498.      stalls due to memory loads generated for spilled pseudo registers.
  499.  
  500.      The option `-dR' causes a debugging dump of the RTL code after
  501.      this pass.  This dump file's name is made by appending `.sched2'
  502.      to the input file name.
  503.  
  504.    * Jump optimization is repeated, this time including cross-jumping
  505.      and deletion of no-op move instructions.
  506.  
  507.      The option `-dJ' causes a debugging dump of the RTL code after
  508.      this pass.  This dump file's name is made by appending `.jump2' to
  509.      the input file name.
  510.  
  511.    * Delayed branch scheduling.  This optional pass attempts to find
  512.      instructions that can go into the delay slots of other
  513.      instructions, usually jumps and calls.  The source file name is
  514.      `reorg.c'.
  515.  
  516.      The option `-dd' causes a debugging dump of the RTL code after
  517.      this pass.  This dump file's name is made by appending `.dbr' to
  518.      the input file name.
  519.  
  520.    * Conversion from usage of some hard registers to usage of a register
  521.      stack may be done at this point.  Currently, this is supported only
  522.      for the floating-point registers of the Intel 80387 coprocessor.
  523.      The source file name is `reg-stack.c'.
  524.  
  525.      The options `-dk' causes a debugging dump of the RTL code after
  526.      this pass.  This dump file's name is made by appending `.stack' to
  527.      the input file name.
  528.  
  529.    * Final.  This pass outputs the assembler code for the function.  It
  530.      is also responsible for identifying spurious test and compare
  531.      instructions.  Machine-specific peephole optimizations are
  532.      performed at the same time.  The function entry and exit sequences
  533.      are generated directly as assembler code in this pass; they never
  534.      exist as RTL.
  535.  
  536.      The source files are `final.c' plus `insn-output.c'; the latter is
  537.      generated automatically from the machine description by the tool
  538.      `genoutput'.  The header file `conditions.h' is used for
  539.      communication between these files.
  540.  
  541.    * Debugging information output.  This is run after final because it
  542.      must output the stack slot offsets for pseudo registers that did
  543.      not get hard registers.  Source files are `dbxout.c' for DBX
  544.      symbol table format, `sdbout.c' for SDB symbol table format, and
  545.      `dwarfout.c' for DWARF symbol table format.
  546.  
  547.    Some additional files are used by all or many passes:
  548.  
  549.    * Every pass uses `machmode.def' and `machmode.h' which define the
  550.      machine modes.
  551.  
  552.    * Several passes use `real.h', which defines the default
  553.      representation of floating point constants and how to operate on
  554.      them.
  555.  
  556.    * All the passes that work with RTL use the header files `rtl.h' and
  557.      `rtl.def', and subroutines in file `rtl.c'.  The tools `gen*' also
  558.      use these files to read and work with the machine description RTL.
  559.  
  560.    * Several passes refer to the header file `insn-config.h' which
  561.      contains a few parameters (C macro definitions) generated
  562.      automatically from the machine description RTL by the tool
  563.      `genconfig'.
  564.  
  565.    * Several passes use the instruction recognizer, which consists of
  566.      `recog.c' and `recog.h', plus the files `insn-recog.c' and
  567.      `insn-extract.c' that are generated automatically from the machine
  568.      description by the tools `genrecog' and `genextract'.
  569.  
  570.    * Several passes use the header files `regs.h' which defines the
  571.      information recorded about pseudo register usage, and
  572.      `basic-block.h' which defines the information recorded about basic
  573.      blocks.
  574.  
  575.    * `hard-reg-set.h' defines the type `HARD_REG_SET', a bit-vector
  576.      with a bit for each hard register, and some macros to manipulate
  577.      it.  This type is just `int' if the machine has few enough hard
  578.      registers; otherwise it is an array of `int' and some of the
  579.      macros expand into loops.
  580.  
  581.    * Several passes use instruction attributes.  A definition of the
  582.      attributes defined for a particular machine is in file
  583.      `insn-attr.h', which is generated from the machine description by
  584.      the program `genattr'.  The file `insn-attrtab.c' contains
  585.      subroutines to obtain the attribute values for insns.  It is
  586.      generated from the machine description by the program `genattrtab'.
  587.  
  588. File: gcc.info,  Node: RTL,  Next: Machine Desc,  Prev: Passes,  Up: Top
  589.  
  590. RTL Representation
  591. ******************
  592.  
  593.    Most of the work of the compiler is done on an intermediate
  594. representation called register transfer language.  In this language,
  595. the instructions to be output are described, pretty much one by one, in
  596. an algebraic form that describes what the instruction does.
  597.  
  598.    RTL is inspired by Lisp lists.  It has both an internal form, made
  599. up of structures that point at other structures, and a textual form
  600. that is used in the machine description and in printed debugging dumps.
  601. The textual form uses nested parentheses to indicate the pointers in
  602. the internal form.
  603.  
  604. * Menu:
  605.  
  606. * RTL Objects::       Expressions vs vectors vs strings vs integers.
  607. * Accessors::         Macros to access expression operands or vector elts.
  608. * Flags::             Other flags in an RTL expression.
  609. * Machine Modes::     Describing the size and format of a datum.
  610. * Constants::         Expressions with constant values.
  611. * Regs and Memory::   Expressions representing register contents or memory.
  612. * Arithmetic::        Expressions representing arithmetic on other expressions.
  613. * Comparisons::       Expressions representing comparison of expressions.
  614. * Bit Fields::        Expressions representing bit-fields in memory or reg.
  615. * Conversions::       Extending, truncating, floating or fixing.
  616. * RTL Declarations::  Declaring volatility, constancy, etc.
  617. * Side Effects::      Expressions for storing in registers, etc.
  618. * Incdec::            Embedded side-effects for autoincrement addressing.
  619. * Assembler::         Representing `asm' with operands.
  620. * Insns::             Expression types for entire insns.
  621. * Calls::             RTL representation of function call insns.
  622. * Sharing::           Some expressions are unique; others *must* be copied.
  623. * Reading RTL::       Reading textual RTL from a file.
  624.  
  625. File: gcc.info,  Node: RTL Objects,  Next: Accessors,  Prev: RTL,  Up: RTL
  626.  
  627. RTL Object Types
  628. ================
  629.  
  630.    RTL uses five kinds of objects: expressions, integers, wide integers,
  631. strings and vectors.  Expressions are the most important ones.  An RTL
  632. expression ("RTX", for short) is a C structure, but it is usually
  633. referred to with a pointer; a type that is given the typedef name `rtx'.
  634.  
  635.    An integer is simply an `int'; their written form uses decimal
  636. digits.  A wide integer is an integral object whose type is
  637. `HOST_WIDE_INT' (*note Config::.); their written form used decimal
  638. digits.
  639.  
  640.    A string is a sequence of characters.  In core it is represented as a
  641. `char *' in usual C fashion, and it is written in C syntax as well.
  642. However, strings in RTL may never be null.  If you write an empty
  643. string in a machine description, it is represented in core as a null
  644. pointer rather than as a pointer to a null character.  In certain
  645. contexts, these null pointers instead of strings are valid.  Within RTL
  646. code, strings are most commonly found inside `symbol_ref' expressions,
  647. but they appear in other contexts in the RTL expressions that make up
  648. machine descriptions.
  649.  
  650.    A vector contains an arbitrary number of pointers to expressions.
  651. The number of elements in the vector is explicitly present in the
  652. vector.  The written form of a vector consists of square brackets
  653. (`[...]') surrounding the elements, in sequence and with whitespace
  654. separating them.  Vectors of length zero are not created; null pointers
  655. are used instead.
  656.  
  657.    Expressions are classified by "expression codes" (also called RTX
  658. codes).  The expression code is a name defined in `rtl.def', which is
  659. also (in upper case) a C enumeration constant.  The possible expression
  660. codes and their meanings are machine-independent.  The code of an RTX
  661. can be extracted with the macro `GET_CODE (X)' and altered with
  662. `PUT_CODE (X, NEWCODE)'.
  663.  
  664.    The expression code determines how many operands the expression
  665. contains, and what kinds of objects they are.  In RTL, unlike Lisp, you
  666. cannot tell by looking at an operand what kind of object it is.
  667. Instead, you must know from its context--from the expression code of
  668. the containing expression.  For example, in an expression of code
  669. `subreg', the first operand is to be regarded as an expression and the
  670. second operand as an integer.  In an expression of code `plus', there
  671. are two operands, both of which are to be regarded as expressions.  In
  672. a `symbol_ref' expression, there is one operand, which is to be
  673. regarded as a string.
  674.  
  675.    Expressions are written as parentheses containing the name of the
  676. expression type, its flags and machine mode if any, and then the
  677. operands of the expression (separated by spaces).
  678.  
  679.    Expression code names in the `md' file are written in lower case,
  680. but when they appear in C code they are written in upper case.  In this
  681. manual, they are shown as follows: `const_int'.
  682.  
  683.    In a few contexts a null pointer is valid where an expression is
  684. normally wanted.  The written form of this is `(nil)'.
  685.  
  686. File: gcc.info,  Node: Accessors,  Next: Flags,  Prev: RTL Objects,  Up: RTL
  687.  
  688. Access to Operands
  689. ==================
  690.  
  691.    For each expression type `rtl.def' specifies the number of contained
  692. objects and their kinds, with four possibilities: `e' for expression
  693. (actually a pointer to an expression), `i' for integer, `w' for wide
  694. integer, `s' for string, and `E' for vector of expressions.  The
  695. sequence of letters for an expression code is called its "format".
  696. Thus, the format of `subreg' is `ei'.
  697.  
  698.    A few other format characters are used occasionally:
  699.  
  700. `u'
  701.      `u' is equivalent to `e' except that it is printed differently in
  702.      debugging dumps.  It is used for pointers to insns.
  703.  
  704. `n'
  705.      `n' is equivalent to `i' except that it is printed differently in
  706.      debugging dumps.  It is used for the line number or code number of
  707.      a `note' insn.
  708.  
  709. `S'
  710.      `S' indicates a string which is optional.  In the RTL objects in
  711.      core, `S' is equivalent to `s', but when the object is read, from
  712.      an `md' file, the string value of this operand may be omitted.  An
  713.      omitted string is taken to be the null string.
  714.  
  715. `V'
  716.      `V' indicates a vector which is optional.  In the RTL objects in
  717.      core, `V' is equivalent to `E', but when the object is read from
  718.      an `md' file, the vector value of this operand may be omitted.  An
  719.      omitted vector is effectively the same as a vector of no elements.
  720.  
  721. `0'
  722.      `0' means a slot whose contents do not fit any normal category.
  723.      `0' slots are not printed at all in dumps, and are often used in
  724.      special ways by small parts of the compiler.
  725.  
  726.    There are macros to get the number of operands, the format, and the
  727. class of an expression code:
  728.  
  729. `GET_RTX_LENGTH (CODE)'
  730.      Number of operands of an RTX of code CODE.
  731.  
  732. `GET_RTX_FORMAT (CODE)'
  733.      The format of an RTX of code CODE, as a C string.
  734.  
  735. `GET_RTX_CLASS (CODE)'
  736.      A single character representing the type of RTX operation that code
  737.      CODE performs.
  738.  
  739.      The following classes are defined:
  740.  
  741.     `o'
  742.           An RTX code that represents an actual object, such as `reg' or
  743.           `mem'.  `subreg' is not in this class.
  744.  
  745.     `<'
  746.           An RTX code for a comparison.  The codes in this class are
  747.           `NE', `EQ', `LE', `LT', `GE', `GT', `LEU', `LTU', `GEU',
  748.           `GTU'.
  749.  
  750.     `1'
  751.           An RTX code for a unary arithmetic operation, such as `neg'.
  752.  
  753.     `c'
  754.           An RTX code for a commutative binary operation, other than
  755.           `NE' and `EQ' (which have class `<').
  756.  
  757.     `2'
  758.           An RTX code for a noncommutative binary operation, such as
  759.           `MINUS'.
  760.  
  761.     `b'
  762.           An RTX code for a bitfield operation (`ZERO_EXTRACT' and
  763.           `SIGN_EXTRACT').
  764.  
  765.     `3'
  766.           An RTX code for other three input operations, such as
  767.           `IF_THEN_ELSE'.
  768.  
  769.     `i'
  770.           An RTX code for a machine insn (`INSN', `JUMP_INSN', and
  771.           `CALL_INSN').
  772.  
  773.     `m'
  774.           An RTX code for something that matches in insns, such as
  775.           `MATCH_DUP'.
  776.  
  777.     `x'
  778.           All other RTX codes.
  779.  
  780.    Operands of expressions are accessed using the macros `XEXP',
  781. `XINT', `XWINT' and `XSTR'.  Each of these macros takes two arguments:
  782. an expression-pointer (RTX) and an operand number (counting from zero).
  783. Thus,
  784.  
  785.      XEXP (X, 2)
  786.  
  787. accesses operand 2 of expression X, as an expression.
  788.  
  789.      XINT (X, 2)
  790.  
  791. accesses the same operand as an integer.  `XSTR', used in the same
  792. fashion, would access it as a string.
  793.  
  794.    Any operand can be accessed as an integer, as an expression or as a
  795. string.  You must choose the correct method of access for the kind of
  796. value actually stored in the operand.  You would do this based on the
  797. expression code of the containing expression.  That is also how you
  798. would know how many operands there are.
  799.  
  800.    For example, if X is a `subreg' expression, you know that it has two
  801. operands which can be correctly accessed as `XEXP (X, 0)' and `XINT (X,
  802. 1)'.  If you did `XINT (X, 0)', you would get the address of the
  803. expression operand but cast as an integer; that might occasionally be
  804. useful, but it would be cleaner to write `(int) XEXP (X, 0)'.  `XEXP
  805. (X, 1)' would also compile without error, and would return the second,
  806. integer operand cast as an expression pointer, which would probably
  807. result in a crash when accessed.  Nothing stops you from writing `XEXP
  808. (X, 28)' either, but this will access memory past the end of the
  809. expression with unpredictable results.
  810.  
  811.    Access to operands which are vectors is more complicated.  You can
  812. use the macro `XVEC' to get the vector-pointer itself, or the macros
  813. `XVECEXP' and `XVECLEN' to access the elements and length of a vector.
  814.  
  815. `XVEC (EXP, IDX)'
  816.      Access the vector-pointer which is operand number IDX in EXP.
  817.  
  818. `XVECLEN (EXP, IDX)'
  819.      Access the length (number of elements) in the vector which is in
  820.      operand number IDX in EXP.  This value is an `int'.
  821.  
  822. `XVECEXP (EXP, IDX, ELTNUM)'
  823.      Access element number ELTNUM in the vector which is in operand
  824.      number IDX in EXP.  This value is an RTX.
  825.  
  826.      It is up to you to make sure that ELTNUM is not negative and is
  827.      less than `XVECLEN (EXP, IDX)'.
  828.  
  829.    All the macros defined in this section expand into lvalues and
  830. therefore can be used to assign the operands, lengths and vector
  831. elements as well as to access them.
  832.  
  833. File: gcc.info,  Node: Flags,  Next: Machine Modes,  Prev: Accessors,  Up: RTL
  834.  
  835. Flags in an RTL Expression
  836. ==========================
  837.  
  838.    RTL expressions contain several flags (one-bit bit-fields) that are
  839. used in certain types of expression.  Most often they are accessed with
  840. the following macros:
  841.  
  842. `MEM_VOLATILE_P (X)'
  843.      In `mem' expressions, nonzero for volatile memory references.
  844.      Stored in the `volatil' field and printed as `/v'.
  845.  
  846. `MEM_IN_STRUCT_P (X)'
  847.      In `mem' expressions, nonzero for reference to an entire
  848.      structure, union or array, or to a component of one.  Zero for
  849.      references to a scalar variable or through a pointer to a scalar.
  850.      Stored in the `in_struct' field and printed as `/s'.
  851.  
  852. `REG_LOOP_TEST_P'
  853.      In `reg' expressions, nonzero if this register's entire life is
  854.      contained in the exit test code for some loop.  Stored in the
  855.      `in_struct' field and printed as `/s'.
  856.  
  857. `REG_USERVAR_P (X)'
  858.      In a `reg', nonzero if it corresponds to a variable present in the
  859.      user's source code.  Zero for temporaries generated internally by
  860.      the compiler.  Stored in the `volatil' field and printed as `/v'.
  861.  
  862. `REG_FUNCTION_VALUE_P (X)'
  863.      Nonzero in a `reg' if it is the place in which this function's
  864.      value is going to be returned.  (This happens only in a hard
  865.      register.)  Stored in the `integrated' field and printed as `/i'.
  866.  
  867.      The same hard register may be used also for collecting the values
  868.      of functions called by this one, but `REG_FUNCTION_VALUE_P' is zero
  869.      in this kind of use.
  870.  
  871. `SUBREG_PROMOTED_VAR_P'
  872.      Nonzero in a `subreg' if it was made when accessing an object that
  873.      was promoted to a wider mode in accord with the `PROMOTED_MODE'
  874.      machine description macro (*note Storage Layout::.).  In this
  875.      case, the mode of the `subreg' is the declared mode of the object
  876.      and the mode of `SUBREG_REG' is the mode of the register that
  877.      holds the object.  Promoted variables are always either sign- or
  878.      zero-extended to the wider mode on every assignment.  Stored in
  879.      the `in_struct' field and printed as `/s'.
  880.  
  881. `SUBREG_PROMOTED_UNSIGNED_P'
  882.      Nonzero in a `subreg' that has `SUBREG_PROMOTED_VAR_P' nonzero if
  883.      the object being referenced is kept zero-extended and zero if it
  884.      is kept sign-extended.  Stored in the `unchanging' field and
  885.      printed as `/u'.
  886.  
  887. `RTX_UNCHANGING_P (X)'
  888.      Nonzero in a `reg' or `mem' if the value is not changed.  (This
  889.      flag is not set for memory references via pointers to constants.
  890.      Such pointers only guarantee that the object will not be changed
  891.      explicitly by the current function.  The object might be changed by
  892.      other functions or by aliasing.)  Stored in the `unchanging' field
  893.      and printed as `/u'.
  894.  
  895. `RTX_INTEGRATED_P (INSN)'
  896.      Nonzero in an insn if it resulted from an in-line function call.
  897.      Stored in the `integrated' field and printed as `/i'.  This may be
  898.      deleted; nothing currently depends on it.
  899.  
  900. `SYMBOL_REF_USED (X)'
  901.      In a `symbol_ref', indicates that X has been used.  This is
  902.      normally only used to ensure that X is only declared external
  903.      once.  Stored in the `used' field.
  904.  
  905. `SYMBOL_REF_FLAG (X)'
  906.      In a `symbol_ref', this is used as a flag for machine-specific
  907.      purposes.  Stored in the `volatil' field and printed as `/v'.
  908.  
  909. `LABEL_OUTSIDE_LOOP_P'
  910.      In `label_ref' expressions, nonzero if this is a reference to a
  911.      label that is outside the innermost loop containing the reference
  912.      to the label.  Stored in the `in_struct' field and printed as `/s'.
  913.  
  914. `INSN_DELETED_P (INSN)'
  915.      In an insn, nonzero if the insn has been deleted.  Stored in the
  916.      `volatil' field and printed as `/v'.
  917.  
  918. `INSN_ANNULLED_BRANCH_P (INSN)'
  919.      In an `insn' in the delay slot of a branch insn, indicates that an
  920.      annulling branch should be used.  See the discussion under
  921.      `sequence' below.  Stored in the `unchanging' field and printed as
  922.      `/u'.
  923.  
  924. `INSN_FROM_TARGET_P (INSN)'
  925.      In an `insn' in a delay slot of a branch, indicates that the insn
  926.      is from the target of the branch.  If the branch insn has
  927.      `INSN_ANNULLED_BRANCH_P' set, this insn should only be executed if
  928.      the branch is taken.  For annulled branches with this bit clear,
  929.      the insn should be executed only if the branch is not taken.
  930.      Stored in the `in_struct' field and printed as `/s'.
  931.  
  932. `CONSTANT_POOL_ADDRESS_P (X)'
  933.      Nonzero in a `symbol_ref' if it refers to part of the current
  934.      function's "constants pool".  These are addresses close to the
  935.      beginning of the function, and GNU CC assumes they can be addressed
  936.      directly (perhaps with the help of base registers).  Stored in the
  937.      `unchanging' field and printed as `/u'.
  938.  
  939. `CONST_CALL_P (X)'
  940.      In a `call_insn', indicates that the insn represents a call to a
  941.      const function.  Stored in the `unchanging' field and printed as
  942.      `/u'.
  943.  
  944. `LABEL_PRESERVE_P (X)'
  945.      In a `code_label', indicates that the label can never be deleted.
  946.      Labels referenced by a non-local goto will have this bit set.
  947.      Stored in the `in_struct' field and printed as `/s'.
  948.  
  949. `SCHED_GROUP_P (INSN)'
  950.      During instruction scheduling, in an insn, indicates that the
  951.      previous insn must be scheduled together with this insn.  This is
  952.      used to ensure that certain groups of instructions will not be
  953.      split up by the instruction scheduling pass, for example, `use'
  954.      insns before a `call_insn' may not be separated from the
  955.      `call_insn'.  Stored in the `in_struct' field and printed as `/s'.
  956.  
  957.    These are the fields which the above macros refer to:
  958.  
  959. `used'
  960.      Normally, this flag is used only momentarily, at the end of RTL
  961.      generation for a function, to count the number of times an
  962.      expression appears in insns.  Expressions that appear more than
  963.      once are copied, according to the rules for shared structure
  964.      (*note Sharing::.).
  965.  
  966.      In a `symbol_ref', it indicates that an external declaration for
  967.      the symbol has already been written.
  968.  
  969.      In a `reg', it is used by the leaf register renumbering code to
  970.      ensure that each register is only renumbered once.
  971.  
  972. `volatil'
  973.      This flag is used in `mem', `symbol_ref' and `reg' expressions and
  974.      in insns.  In RTL dump files, it is printed as `/v'.
  975.  
  976.      In a `mem' expression, it is 1 if the memory reference is volatile.
  977.      Volatile memory references may not be deleted, reordered or
  978.      combined.
  979.  
  980.      In a `symbol_ref' expression, it is used for machine-specific
  981.      purposes.
  982.  
  983.      In a `reg' expression, it is 1 if the value is a user-level
  984.      variable.  0 indicates an internal compiler temporary.
  985.  
  986.      In an insn, 1 means the insn has been deleted.
  987.  
  988. `in_struct'
  989.      In `mem' expressions, it is 1 if the memory datum referred to is
  990.      all or part of a structure or array; 0 if it is (or might be) a
  991.      scalar variable.  A reference through a C pointer has 0 because
  992.      the pointer might point to a scalar variable.  This information
  993.      allows the compiler to determine something about possible cases of
  994.      aliasing.
  995.  
  996.      In an insn in the delay slot of a branch, 1 means that this insn
  997.      is from the target of the branch.
  998.  
  999.      During instruction scheduling, in an insn, 1 means that this insn
  1000.      must be scheduled as part of a group together with the previous
  1001.      insn.
  1002.  
  1003.      In `reg' expressions, it is 1 if the register has its entire life
  1004.      contained within the test expression of some loopl.
  1005.  
  1006.      In `subreg' expressions, 1 means that the `subreg' is accessing an
  1007.      object that has had its mode promoted from a wider mode.
  1008.  
  1009.      In `label_ref' expressions, 1 means that the referenced label is
  1010.      outside the innermost loop containing the insn in which the
  1011.      `label_ref' was found.
  1012.  
  1013.      In `code_label' expressions, it is 1 if the label may never be
  1014.      deleted.  This is used for labels which are the target of
  1015.      non-local gotos.
  1016.  
  1017.      In an RTL dump, this flag is represented as `/s'.
  1018.  
  1019. `unchanging'
  1020.      In `reg' and `mem' expressions, 1 means that the value of the
  1021.      expression never changes.
  1022.  
  1023.      In `subreg' expressions, it is 1 if the `subreg' references an
  1024.      unsigned object whose mode has been promoted to a wider mode.
  1025.  
  1026.      In an insn, 1 means that this is an annulling branch.
  1027.  
  1028.      In a `symbol_ref' expression, 1 means that this symbol addresses
  1029.      something in the per-function constants pool.
  1030.  
  1031.      In a `call_insn', 1 means that this instruction is a call to a
  1032.      const function.
  1033.  
  1034.      In an RTL dump, this flag is represented as `/u'.
  1035.  
  1036. `integrated'
  1037.      In some kinds of expressions, including insns, this flag means the
  1038.      rtl was produced by procedure integration.
  1039.  
  1040.      In a `reg' expression, this flag indicates the register containing
  1041.      the value to be returned by the current function.  On machines
  1042.      that pass parameters in registers, the same register number may be
  1043.      used for parameters as well, but this flag is not set on such uses.
  1044.  
  1045. ə